package com.atguigu.tingshu.user.client;

import cn.hutool.core.bean.BeanUtil;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.model.user.UserInfo;
import com.atguigu.tingshu.model.user.VipServiceConfig;
import com.atguigu.tingshu.user.client.impl.UserDegradeFeignClient;
import com.atguigu.tingshu.vo.user.UserInfoVo;
import com.atguigu.tingshu.vo.user.UserPaidRecordVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 产品列表API接口
 * </p>
 *
 * @author atguigu
 */
@FeignClient(value = "service-user", path = "/api/user",fallback = UserDegradeFeignClient.class)
public interface UserFeignClient {


    /**
     * 判断用户是否购买过指定专辑
     * @param albumId
     * @return
     */
    @GetMapping("/userInfo/isPaidAlbum/{albumId}")
    Result<Boolean> isPaidAlbum(@PathVariable Long albumId);
    /**
     *  根据userID获取用户信息
     * @param userId
     * @return
     */
    @GetMapping("userInfo/getUserInfoVo/{userId}")
    Result<UserInfoVo> getUserInfoVo(@PathVariable Long userId);

    /**
     * 根据id获取VIP服务配置信息
     * @param id
     * @return
     */
    @GetMapping("/vipServiceConfig/getVipServiceConfig/{id}")
    Result<VipServiceConfig> getVipServiceConfig(@PathVariable Long id);

    /**
     * 该接口提供给给专辑服务，展示声音列表动态判断付费标识
     * 判断当前用户某一页中声音列表购买情况
     *
     * @param userId               用户ID
     * @param albumId              专辑ID
     * @param needChackTrackIdList 待检查购买情况声音列表
     * @return data:{声音ID：购买结果}   结果：1（已购）0（未购买）
     */
    @PostMapping ("/userInfo/userIsPaidTrack/{userId}/{albumId}")
    Result<Map<Long,Integer>> userIsPaidTrack(@PathVariable Long userId, @PathVariable Long albumId, @RequestBody List<Long> needChackTrackIdList);

    /**
     * 根据专辑id+用户ID获取用户已购买声音id列表
     * @param albumId
     * @return
     */
    @GetMapping("/userInfo/findUserPaidTrackList/{albumId}")
    Result<List<Long>> findUserPaidTrackList(@PathVariable Long albumId);

    /**
     * 保存订单记录
     * @param userPaidRecordVo
     * @return
     */
    @PostMapping("/userInfo/savePaidRecord")
    Result savePaidRecord(@RequestBody UserPaidRecordVo userPaidRecordVo);

}
